package com.niiwoo.civet.trade.dao.mapper;

import com.niiwoo.civet.trade.dao.entity.ProjectContract;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Component
public interface ProjectContractMapperExt extends ProjectContractMapper {
    /**
     * 查询用户在指定标的签署的指定类型合同
     *
     * @param userId
     * @param projectId
     * @param contractType
     * @return
     */
    ProjectContract queryProjectContractByUserIdAndProjectIdAndContractType(@Param("userId") String userId,
                                                                            @Param("projectId") Long projectId, @Param("contractType") Byte contractType);

    /**
     * 根据标的ID和合同类型查询最新合同信息
     *
     * @param projectId
     * @param contractType
     * @return
     */
    ProjectContract queryProjectContractByProjectIdAndContractType(@Param("projectId") Long projectId, @Param("contractType") Byte contractType);

    /**
     * 根据合同编号查询合同信息
     *
     * @param userId
     * @param contractNo
     * @return
     */
    ProjectContract queryProjectContractByUserIdAndContractNo(@Param("userId") String userId, @Param("contractNo") String contractNo);

    /**
     * 根据用户Id、合同编号更新合同信息数据
     *
     * @param record
     * @return
     */
    int updateByUserIdContractNoSelective(ProjectContract record);

    List<ProjectContract> queryFastLoanContractByProjectIdSet(@Param("projectIdSet") Set<Long> projectIdSet);

    /**
     * 获取指定标的 借款类型的法大大最新的合同URL地址
     *
     * @param projectId
     * @return
     */
    String findNewestByProjectIdAndContractType(@Param("projectId") Long projectId,@Param("contractType") byte contractType);


    int selectCommissionAuthCountByType(@Param("userId") String userId, @Param("contractType") Byte contractType, @Param("tradeType") Byte tradeType);

    List<ProjectContract> queryByPageWithUserAndType(@Param("userId") String userId, @Param("contractType") Byte contractType, @Param("tradeType") Byte tradeType,
                                                     @Param("offset") Integer offset, @Param("size") Integer size);

    /**
     * 查询考拉债权转让合同
     *
     * @param borrowUserId
     * @param contractNo
     * @param projectId
     * @param contractType
     * @return
     */
    ProjectContract queryProjectContract4KaoLaDebt(@Param("userId") String borrowUserId,
                                                   @Param("contractNo") String contractNo,
                                                   @Param("projectId") Long projectId,
                                                   @Param("contractType") Byte contractType);

    List<ProjectContract> queryInvestRiskTipsContactByProjectIdSet(@Param("userId") String userId, @Param("projectIdSet") Set<Long> projectIdSet);

    /**
     * 查询智能投相关合同
     * @param userId 用户ID
     * @param packageId 包的ID
     * @param contractTypeList 合同类型
     * @return
     */
    List<ProjectContract> queryIntelligenceInvestProtocollo(@Param("userId") String userId, @Param("packageId") Long packageId,
                                                            @Param("contractTypeList") List<Byte> contractTypeList);
}